package blackhouse_servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import blackhouse_server.classcj_check2_server;

import com.alibaba.fastjson.JSON;

@WebServlet("/classcj2")
public class Classcj_check2 extends HttpServlet
{
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException
	{
		doGet(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException
	{
		req.setCharacterEncoding("utf-8");
		resp.setCharacterEncoding("utf-8");
		String ID = (String) req.getSession().getAttribute("user");
		int subCode = 0;
		if (req.getParameter("subcode") != null)
		{
			if (!req.getParameter("subcode").trim().equals(""))
				subCode = Integer.parseInt(req.getParameter("subcode"));
		}
		classcj_check2_server cc = new classcj_check2_server();
		String json;
		try
		{
			json = JSON.toJSONString(cc.readyresult(ID, subCode));
			PrintWriter PW = resp.getWriter();
			PW.write(json);
		} catch (SQLException e)
		{

			e.printStackTrace();
		}

	}
}
